/**
 * Created by IntelliJ IDEA.
 * User: Liu Yuhong
 * Date: 12-10-3
 * Time: 下午7:02
 * Test.
 */

$(function() {

    $( "#epApprove" ).UIApprove({ 'stars': 4, 'alignCenter': true });

 

    $( "#orderList .title_label" ).click(function() {
        this.blur();
        var labelContent = $( "#" + $( this ).attr("href").split("#")[1] );
        var nullContent = $( "#" + $( this ).attr("href").split("#")[2] );
        var classSel = labelContent.attr("class").split(" ")[0];
        $( this ).parents(".channel_box").find("."+classSel).addClass("hidden");
        labelContent.removeClass("hidden");
        nullContent.removeClass("hidden");
        $( this ).parent().find( ".active.single_bd" ).addClass("gradient_bd").removeClass("active single_bd");
        $( this ).removeClass("gradient_bd").addClass("active single_bd");
        return false;
    });

//    $( "#orderTable1 tbody td" ).click(function() {
//        this.blur();
//        var hiddenDetail = $( this ).parent("tr").next(".hidden_detail");
//        $( ".hidden_detail" ).not(hiddenDetail).find("div").slideUp(function() {
//            $( this ).parents(".hidden_detail").hide();
//        });
//        if($( hiddenDetail ).css("display") == "none") {
//            $( hiddenDetail ).show();
//            $( hiddenDetail ).find("div").slideDown();
//        }else {
//            $( hiddenDetail ).find("div").slideUp(function() {
//                $( hiddenDetail ).hide();
//            });
//        }
//    });

    $( "#releasedList .title_label" ).click(function() {
        this.blur();
        var labelContent = $( "#" + $( this ).attr("href").split("#")[1] );
        $( this ).parents(".channel_box").find("ul").not(".hidden").addClass("hidden");
        labelContent.removeClass("hidden");
        $( this ).parent().find(".active").removeClass("active");
        $( this ).addClass("active");
        if($( this ).prev().length == 0) $( this ).css({ 'borderLeft': 0 });
        return false;
    });

    $( "#vmiQuery input" ).UITipInside();

    $( "#vmiQuerySubmit" ).click(function() {
        this.blur();
        
        //这个功能的开发人员还没有提供链接的页面，可以联系开发《VMI的开发人员》;
        return false;
        
      //  $( this ).parents("form").submit();
       // return false;
    });
});

//function openCurrentStep(ebvpPath,pkProj,pkProjStep,type,stepName,fig){
//	window.open(getUrl(ebvpPath,type,pkProj,pkProjStep,fig),stepName);
//}
//
////获取环节响应URL
//function getUrl(ebvpPath,type,pkProj,pkProjStep,fig){
//	var url = null;
//	if(type == "001"){
//		url = ebvpPath + "/sourcing/biddingprojlist/releaseinviteinfo?pkProj="+pkProj+"&pkProjStep="+pkProjStep;
//	}else if(type == "002" || type == "003"){
//		var resValue = isNeedReply(pkProjStep);
//		if(null != resValue && "N" === resValue){
//			//不需要对该环节进行应答;
//			//return;
//		}
//		url = ebvpPath + "/sourcing/biddingprojlist/releasepurfileinfo?pkProj="+pkProj+"&pkProjStep="+pkProjStep+"&type="+type;
//	}else if(type == "004"){
//		url = ebvpPath + "/sourcing/biddingprojlist/reginfo?pkProj="+pkProj+"&pkProjStep="+pkProjStep;
//	}else if(type == "0091"){
//		url = ebvpPath + "/sourcing/biddingprojlist/tpltinfo?pkProj="+pkProj+"&pkProjStep="+pkProjStep;
//	}else if(type == "0092"){
//		url = ebvpPath + "/sourcingcoll/quotelogin_new.jsp?pkProj="+pkProj+"&pkProjStep="+pkProjStep;
//	}else if(type == "0093"){
//		url = ebvpPath + "/sourcing/biddingprojlist/getoldquote?projPk="+pkProj+"&pkProjStep="+pkProjStep+"&quote_index=0&isconfirm=1";
//	}else if(type == "010"){
//		url = ebvpPath + "/sourcing/projexec/resultinform?pkProj="+pkProj+"&pkProjStep="+pkProjStep+"&fig="+fig;
//	}
//	return url;
//}

function showDetailsExe(pkOrder,comp){
	//return;
	comp.blur();
	var hiddenDetail = $( comp ).next(".hidden_detail");
	var msgPlanArrive= getLanMsgs("ec22180-000089");
	var myts = new Date();
	if(hiddenDetail.find("ul").length == 0){
		jQuery.ajax( {
			type : "POST",
			async : false,
			url : "/ebvp/order/qryOrderDetailsExe?myts=" + myts,
			dataType : "text",
			data : "&pkOrder=" + pkOrder,
			success : function(result) {
				if(result != "[]"){
					var orderItems = eval(result);
					var orderItemDiv = $("#"+pkOrder+"_2");
					for ( var loop = 0; loop < orderItems.length && loop <= 2; loop++) {
						var orderItem = orderItems[loop];
						var li_1 = $("<li></li>").addClass("column1").html(orderItem.prodName);								
						var li_2 = $("<li></li>").addClass("column2").html(orderItem.orderNum + orderItem.measureName);
						var li_3 = $("<li></li>").addClass("columnn3").html(orderItem.priceTaxTotal + orderItem.curName);
						var objSpan1 = $("<span></span>").html(msgPlanArrive+orderItem.planArrDate);
						//var objSpan2 = $("<span></span>").html(orderItem.planArrDate);
						var li_4 = $("<li></li>").addClass("columnn4").append(objSpan1);//.append(objSpan2);
						//var objLi = li_1.append(li_2).append(li_3).append(li_4);
						var objUl = $("<ul></ul>").addClass("bdbtm");
						objUl.append(li_1).append(li_2).append(li_3).append(li_4)
						orderItemDiv.append(objUl);
					}
				}
			}				
		});
	}
    $( ".hidden_detail" ).not(hiddenDetail).find("div").slideUp(function() {
        $( comp ).parents(".hidden_detail").hide();
    });
    if($( hiddenDetail ).css("display") == "none") {
        $( hiddenDetail ).show();
        $( hiddenDetail ).find("div").slideDown();
    }else {
        $( hiddenDetail ).find("div").slideUp(function() {
            $( hiddenDetail ).hide();
        });
    }
}

function showDetailsStatus(pkOrder,pkWebOrder,comp){
	//return;
	comp.blur();
	var hiddenDetail = $( comp ).next(".hidden_detail");
	var msgPlanArrive= getLanMsgs("ec22180-000089");
	var msgStatusTitle= getLanMsgs("ec22180-000107");
	var msgStatus1= getLanMsgs("ec22180-000079");
	var msgStatus2= getLanMsgs("ec22180-000080");
	var msgStatus3= getLanMsgs("ec22180-000081");
	var msgStatus4= getLanMsgs("ec22180-000082");
	var msgStatus5= getLanMsgs("ec22180-000083");
	var msgStatus6= getLanMsgs("ec22180-000084");
	var myts = new Date();
	if(hiddenDetail.find("ul").length == 0){
		jQuery.ajax( {
			type : "POST",
			async : false,
			url : "/ebvp/order/qryOrderDetailsStatus?myts=" + myts,
			dataType : "text",
			data : "&pkOrder=" + pkOrder + "&pkWebOrder=" + pkWebOrder,
			success : function(result) {
				if(result != "[]"){
					var orderItems = eval(result);
					var orderItemDiv = $("#"+pkOrder+"_1");
					for ( var loop = 0; loop < orderItems.length && loop <= 2; loop++) {
						var orderItem = orderItems[loop];
						var li_1 = $("<li></li>").addClass("column1").html(orderItem.prodName);								
						var li_2 = $("<li></li>").addClass("column2").html(orderItem.orderNum + orderItem.measureName);
						var objSpan1 = $("<span></span>").html(msgPlanArrive+orderItem.planArrDate);
						//var objSpan2 = $("<span></span>").html(orderItem.planArrDate);
						var li_3 = $("<li></li>").addClass("column3").append(objSpan1);//.append(objSpan2);
						//var objLi = li_1.append(li_2).append(li_3).append(li_4);
						var statusHtml = "";
						if(1 == orderItem.prodStatus){
							statusHtml = msgStatusTitle + msgStatus1;
						}else if(2 == orderItem.prodStatus){
							statusHtml = msgStatusTitle + msgStatus2;
						}else if(3 == orderItem.prodStatus){
							statusHtml = msgStatusTitle + msgStatus3;
						}else if(4 == orderItem.prodStatus){
							statusHtml = msgStatusTitle + msgStatus4;
						}else if(5 == orderItem.prodStatus){
							statusHtml = msgStatusTitle + msgStatus5;
						}else if(null == orderItem.prodStatus){
							statusHtml = msgStatusTitle + msgStatus6;
						}
						var li_4 = $("<li></li>").addClass("column4").html(statusHtml);
						var objUl = $("<ul></ul>").addClass("bdbtm");
						objUl.append(li_1).append(li_2).append(li_3).append(li_4)
						orderItemDiv.append(objUl);
					}
				}
			}				
		});
	}
    $( ".hidden_detail" ).not(hiddenDetail).find("div").slideUp(function() {
        $( comp ).parents(".hidden_detail").hide();
    });
    if($( hiddenDetail ).css("display") == "none") {
        $( hiddenDetail ).show();
        $( hiddenDetail ).find("div").slideDown();
    }else {
        $( hiddenDetail ).find("div").slideUp(function() {
            $( hiddenDetail ).hide();
        });
    }
}